package com.winz.cultureapp.utils;

import android.graphics.Rect;
import androidx.recyclerview.widget.RecyclerView;
import android.view.View;

import com.mine.xrecyclerview.XRecyclerView;

public class MarginDecoration extends RecyclerView.ItemDecoration {
    private int margin;
    private int spanCount;
    private View tagView;

    public MarginDecoration(View tagView, int margin, int spanCount) {
        this.margin = margin;
        this.spanCount = spanCount;
        this.tagView = tagView;
    }

    @Override
    public void getItemOffsets(Rect outRect, View view, RecyclerView parent, RecyclerView.State state) {
        if (tagView instanceof XRecyclerView){
            int position = parent.getChildLayoutPosition(view) - 1;
            //不是第一个的格子都设一个左边和底部的间距
            outRect.left = margin;
            outRect.right = margin;
            outRect.bottom = margin;
            outRect.top = margin;
        }



    }
}